﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TestKontrole2 {
    public class Element : TestKontrole2.IElement {

        private string nazivElementa;
        private string opisElementa;
        private int idElement;
        private DateTime datumElementa;

        virtual public string Naziv {
            get { return nazivElementa; }
            set { nazivElementa = value; }
        }

        virtual public string Opis {
            get { return opisElementa; }
            set { opisElementa = value; }
        }

        virtual public int IdElement {
            get { return idElement; }
            set { idElement = value; }
        }

        virtual public DateTime Datum {
            get { return datumElementa; }
            set { datumElementa = value; }
        }

        public Element() {
        }

        public Element(int id) {
            idElement = id;
        }
        public Element(int id, string naziv)
            : this(id) {
            this.nazivElementa = naziv;
        }
        public Element(int id, string naziv, DateTime datum)
            : this(id, naziv) {
            datumElementa = datum;
        }
        public Element(int id, string naziv, DateTime datum, string opis)
            : this(id, naziv, datum) {
            opisElementa = opis;
        }

        #region IElement Members

        virtual public int getID() {
            return idElement;
        }

        virtual public string getOpisElementa() {
            return opisElementa;
        }

        virtual public DateTime getDatum() {
            return datumElementa;
        }

        virtual public string getNaziv() {
            return nazivElementa;
        }

        virtual public void setOpisElementa(string opis) {
            opisElementa = opis;
        }

        #endregion

        // override object.Equals
        public override bool Equals(object obj){
            if (obj == null || GetType() != obj.GetType()){
                return false;
            }
            if (idElement.Equals(((Element) obj).IdElement)) return true;

            return false;
        }

        // override object.GetHashCode
        public override int GetHashCode() {
            return idElement.GetHashCode();
        }
    }
}
